/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.xuexiang.xui_lib.component.edittext;

import ohos.agp.components.AttrSet;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.TextField;
import ohos.app.Context;
import ohos.miscservices.inputmethodability.InputMethodAbility;
import ohos.miscservices.inputmethodability.KeyboardDelegate;

/**
 * 输入法拦截
 *
 * @since 2021-03-24
 */
public class PwdEditText extends TextField {
    //private InputMethodAbility mInputConnection;

    /**
     * 构造函数
     *
     * @param context
     */
    public PwdEditText(Context context) {
        super(context);
        init();
    }

    /**
     * 构造函数
     *
     * @param context
     * @param attrSet
     */
    public PwdEditText(Context context, AttrSet attrSet) {
        super(context, attrSet);
        init();
    }

    /**
     * 构造函数
     *
     * @param context
     * @param attrSet
     * @param styleName
     */
    public PwdEditText(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
        init();
    }
    /**
     * 当输入法和EditText建立连接的时候会通过这个方法返回一个InputConnection。
     * 我们需要代理这个方法的父类方法生成的InputConnection并返回我们自己的代理类。
     * */
    private void init() {
        /*mInputConnection = new InputMethodAbility() {
            @Override
            protected KeyboardDelegate onCreateKeyboardInterface() {
                return null; // 输入法能力开始时调用
            }

            @Override
            protected ComponentContainer onCreateKeyboardContainer() {
                return super.onCreateKeyboardContainer(); // 创建输入法键盘窗口时调用
            }
        };*/
    }

    @Override
    public void setInputMethodOption(int option) {
        super.setInputMethodOption(option);
    }
}
